export const h =(tag,props,children)=>{
    return{
        tag,
        props,
        children
    }
}
export const mount = (vnode, container) => {
    const el = vnode.el = document.createElement(vnode.tag)
    if(vnode.props){
        for(const key in vnode.props){
            el.setAttribute(key,vnode.props[key])
        }
    }
    if(vnode.children){
        if(typeof vnode.children === "string"){
            el.textContent = vnode.children
        } else {
            vnode.children.forEach(item => {
                mount(item,el)
            });
        }
    }
    container.appendChild(el)
}
export const createApp = (app) => {
    const vnode = app.render()
    return {
        $mount(id) {
            const container = document.querySelector(id)
            mount(vnode,container)
        }
    }
}

